#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
int main()
{
	int i = 0;
	int j = 0;
	scanf("%d %d",&i,&j);
	int arr1[i];
	int arr2[j];
	int k = 0;
	for (k = 1;k <= i;k++)
	{
		scanf("%d",&arr1[k-1]);
	}
	for (k = 1;k <= j;k++)
	{
		scanf("%d",&arr2[k-1]);
	}
	int m = 0;
	int n = 0;
	while (m + n <= i + j-2)
	{
		if (m == i)
		{
			for (n;n < j;n++)
			{
				printf("%d ", arr2[n]);
			}
			break;
		}
		if (n == j)
		{
			for (m;m < i;m++)
			{
				printf("%d ",arr1[m]);
			}
			break;
		}
		if (arr1[m] < arr2[n])
		{
			printf("%d ",arr1[m]);
			m++;
		}
		else
		{
			printf("%d ",arr2[n]);
			n++;
		}
	}
	return 0;
}
